private var MainCamera : GameObject;
private var ProjectilePrefab : GameObject;
private var PlayerSpeed : float = 2; 

function Start()
{
	MainCamera = GameObject.Find("Main Camera"); 
	//ProjectilePrefab = GameObject.Find("P_Projectile");
}

function Update () 
{
	var MouseWorldPosition : Vector3 = MainCamera.camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
    transform.LookAt(MouseWorldPosition);
    transform.rotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y, 0));

    // Amount to move
    var inputX = Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime;
    var inputY = Input.GetAxis("Vertical") * PlayerSpeed * Time.deltaTime;

    // Move the Player
    transform.Translate(Vector3.left * inputX);
    transform.Translate(Vector3.forward * inputY);

    if (Input.GetKeyDown("space"))
    {
        //fire projectile
        var projectile : GameObject = Instantiate(Resources.Load("ProjectilePrefab"), transform.position, transform.rotation);
		projectile.GetComponent("Projectile").source = "Player";
    }
}